package test_cases

import (
	"gitee.com/xiangxiaoc/elevator/models"
	"log"
	"time"
)

func RunCase4() {

	eleSys := models.ElevatorSystem{
		TotalFloorNum: 11,
		Elevator: models.Elevator{
			Name:          "三菱电梯",
			CurrentFloor:  1,
			RunningStatus: "停止",
			DoorStatus:    "已关闭",
		},
		ElevatorDestList: []int{2, 5, 11},
	}
	log.Println("Case 4 =====")
	log.Printf("获取楼层数：%v", eleSys.TotalFloorNum)
	time.Sleep(2 * time.Second)
	log.Printf("目标楼层队列：%v", eleSys.ElevatorDestList)
	time.Sleep(2 * time.Second)
	// 模拟一个人在 8 层按了电梯
	log.Printf("模拟一个人在 8 层按了电梯")
	time.Sleep(2 * time.Second)
	p1 := models.Passenger{
		Name:     "大橙",
		Location: 8,
	}
	p1.PushButton(&eleSys)

	for len(eleSys.ElevatorDestList) > 0 {
		log.Printf("目标楼层队列：%v", eleSys.ElevatorDestList)
		time.Sleep(2 * time.Second)
		eleSys.RequestElevatorToFloor(&eleSys.Elevator)
	}
	eleSys.Elevator.LogElevator()
	time.Sleep(3 * time.Second)
}
